package cn.jiyun.function.controller;

import cn.jiyun.Result.Result;
import cn.jiyun.function.service.OrderBillService;
import cn.jiyun.pojo.Orders;
import com.github.pagehelper.PageInfo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("orderBill")
@Slf4j
@RequiredArgsConstructor
public class OrderBillController {
    @Autowired
    OrderBillService orderBillService;
//    @Autowired
//    ExcelService excelService;
    /**
     * 查询所有订单信息
     *
     * @param pageNum 页码，默认为1
     * @param pageSize 每页记录数，默认为10
     * @param orders 订单对象，用于筛选查询条件
     * @return 返回包含订单信息的PageInfo对象
     */
    @RequestMapping("findAll")
    public Result findAll(@RequestParam(name="pageNum" ,defaultValue = "1")Integer pageNum,
                          @RequestParam(name="pageSize",defaultValue = "10") Integer pageSize,
                          @RequestBody Orders orders
                         ) {
        PageInfo<Orders> page = orderBillService.findPage(pageNum,pageSize,orders);
        return Result.ok(page);
    }

    /**
     * 查询订单详情
     *
     * @param id 订单ID
     * @return 返回指定ID的订单对象
     */
    @RequestMapping("particulars")
    public Result particulars(Integer id) {
        Orders orders = orderBillService.particulars(id);
        return Result.ok(orders);
    }

}
